<template>
  <view>
    <u-tabbar
      :value="vuex_pathIndex"
      :fixed="true"
      :placeholder="true"
      :safe-area-inset-bottom="true"
      active-color="#FF5533"
      @change="tabChangeFn"
    >
      <u-tabbar-item text="首页">
        <text
          slot="active-icon"
          class="active-icon t-icon t-icon-shouyefill_tongyong_1"
        />
        <text
          slot="inactive-icon"
          class="active-icon t-icon t-icon-shouyestroke_tongyong_1"
        />
      </u-tabbar-item>
      <u-tabbar-item text="订单">
        <text
          slot="active-icon"
          class="active-icon t-icon t-icon-dingdanfill_tongyong_1"
        />
        <text
          slot="inactive-icon"
          class="active-icon t-icon t-icon-dingdanstroke_tongyong_1"
        />
      </u-tabbar-item>
      <u-tabbar-item text="我的">
        <text
          slot="active-icon"
          class="active-icon t-icon t-icon-wodefill_tongyong_1"
        />
        <text
          slot="inactive-icon"
          class="active-icon t-icon t-icon-wodestroke_tongyong_1"
        />
      </u-tabbar-item>
    </u-tabbar>
  </view>
</template>

<script>

export default {
  name: 'Tabbar',
  data() {
    return {
      pagePaths: [
        '/pages/index/index', //首页
        // '/pages/order/index', //订单
        '/pages/order/moreOrder', //订单
        '/pages/myAccount/index' //我的
      ]
    }
  },
  mounted() {
    this.setPagePathsFn()
  },
  methods: {
    setPagePathsFn() {
      /*if (!this.vuex_loginStatus || (this.vuex_loginStatus && this.vuex_memberInfo && this.vuex_memberInfo.accountType == 20)) {
        this.pagePaths = [
          '/shopIndex/shopIndex', //云采首页
          '/goodsGroup/goodsGroup/index', //分类
          '/purchaseOrder/index', //购物车
          '/pages/order/index', //订单
          '/pages/myAccount/index' //我的
        ]
      }*/
      const pages = getCurrentPages()
      const curPagePath = pages[pages.length - 1].route
      this.$u.vuex('vuex_pathIndex', this.pagePaths.indexOf('/' + curPagePath))
    },
    tabChangeFn(index) {
      this.$u.vuex('vuex_pathIndex', index)
      uni.redirectTo({ url: this.pagePaths[index] })
    }
  }
}
</script>

<style>
.u-tabbar--fixed {
  z-index: 9;
}
.active-icon{
  width: 52rpx;
  height: 52rpx;
}
</style>
